
let activity_tag = 'ysfsfq'
let request_key = 'help'

function sfqcj($request,body) {
    console.log(`开始完成送福气抽奖`);
    console.log( body.data)
    let availableTimes = body.data.availableTimes
    // setTimeout(axios_skill,2000,useridArray[7],$request);
    for (let j = 0; j < availableTimes; j++) {
        
        setTimeout(axios_skill,(j+1)*5000,$request,j+1);
    }
    
}

//上面是暂时需要适配的部分
!(async () => {
    if (typeof $request !== "undefined") {
        let body = $response.body;
        body = JSON.parse(body)
        body.data.questsStatusVOList[1].finishTimes = 8
        $done(JSON.stringify(body))
        // $done(body)
        sfqcj($request,body)
    }
})()
    .catch((e) => console.log(e))
    .finally(() => $done())

function axios_skill(request_body,count) {
    console.log('第'+count+'次抽奖');
    var request_lib = require('request');
    var headers = {
        'Host': 'youhui.95516.com',
        'Origin': 'https://youhui.95516.com',
        'Accept-Encoding': 'gzip, deflate, br',
        'Connection': 'keep-alive',
        'Accept': 'application/json, text/plain, */*',
        'User-Agent': request_body.headers['User-Agent'],
        'Authorization': request_body.headers.Authorization,
        'Referer': 'https://youhui.95516.com/newsign/ysfsfq/index.html',
        'Accept-Language': 'zh-cn',
        'Cookie': request_body.headers.Cookie
    };
    
    var options = {
        url: 'https://youhui.95516.com/newsign/ysfsfq/api/user/drumming',
        method: 'POST',
        headers: headers
    };

    request_lib(options, callback);

}

function callback(error, response, body) {
    console.log(body);
}